package com.dhecp.project.finance.service.impl;

import com.alibaba.fastjson.JSON;
import com.dhecp.common.core.domain.AjaxResult;
import com.dhecp.common.utils.MessageUtils;
import com.dhecp.common.utils.RandomValueUtils;
import com.dhecp.common.utils.TypeUtils;
import com.dhecp.core.constant.DataFiltering;
import com.dhecp.core.constant.ModuleTable;
import com.dhecp.core.utils.ReflectUtils;
import com.dhecp.framework.util.ShiroUtils;
import com.dhecp.project.common.domain.ModuleNID;
import com.dhecp.project.common.domain.RecordCheck;
import com.dhecp.project.common.domain.UpdateFlow;
import com.dhecp.project.common.service.impl.BaseModuleServiceImpl;
import com.dhecp.project.finance.domain.AccountDetailedForCompany;
import com.dhecp.project.finance.domain.TcwCapitalBusinessCost;
import com.dhecp.project.finance.domain.TcwCapitalBusinessCostSon;
import com.dhecp.project.finance.domain.TcwCapitalRegisterClaim;
import com.dhecp.project.finance.mapper.*;
import com.dhecp.project.finance.service.AccountDetailedForCompanyService;
import com.dhecp.project.finance.service.TcwCapitalBusinessCostService;
import com.dhecp.project.flowable.mapper.SysProcessInstanceMapper;
import com.dhecp.project.flowable.service.ActProcessService;
import com.dhecp.project.hr.domain.OperateCompanyApply;
import com.dhecp.project.hr.mapper.OperateCompanyApplyMapper;
import com.dhecp.project.system.service.SysDictionaryForFieldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

import java.math.BigDecimal;
import java.util.*;

/**
 * 运营费用认领单实现类
 *
 */
@Service
public class TcwCapitalBusinessCostServiceImpl extends BaseModuleServiceImpl implements TcwCapitalBusinessCostService {
    private String moduleTable = ModuleTable.TCW_CAPITALBUSINESSCOST;
    private String moduleTable1 = ModuleTable.TCW_CAPITALBUSINESSCOSTSON;
    @Autowired
    private TcwCapitalBusinessCostMapper tcwCapitalBusinessCostMapper;
    
    @Autowired
    private SysDictionaryForFieldService dictionaryForFieldService;

    @Autowired
    private TcwCapitalBusinessCostSonMapper tcwCapitalBusinessCostSonMapper;

    @Autowired
    private AccountDetailedForCompanyService accountDetailedForCompanyService;

    @Autowired
    private AccountDetailedForCompanyMapper accountDetailedForCompanyMapper;

    @Autowired
    private AccountCountForCompanyMapper accountCountForCompanyMapper;
    @Autowired
    private OperateCompanyApplyMapper operateCompanyApplyMapper;
    @Autowired
    private TcwCapitalRegisterClaimMapper tcwCapitalRegisterClaimMapper;

    @Autowired
    private SysProcessInstanceMapper processInstanceMapper;


    @Autowired
    private ActProcessService actProcessService;


    /**
     * 通过guid查询单条数据
     *
     * @param params 对象
     * @return 实例对象
     */
    @Override
    public TcwCapitalBusinessCost queryFirstRecord(Map<String, Object> params) throws Exception{
        params.put(DataFiltering.TABLE_ALIAS, "t1");	//查询表别名
        params.put(DataFiltering.DATA_SCODE, dictionaryForFieldService.getDataScode(params));	//数据权限查询条件SQL语句
        return tcwCapitalBusinessCostMapper.selectFirstRecordByNid(params);
    }



    /**
    * 查询列表数据
    */
    @Override
    public List<TcwCapitalBusinessCost> queryList(Map<String, Object> params) throws Exception{
        params.put(DataFiltering.TABLE_ALIAS, "t1");	//查询表别名
        params.put(DataFiltering.DATA_WHERE, dictionaryForFieldService.getWhereStr(params));	//常规查询条件SQL语句
        params.put(DataFiltering.DATA_SCODE, dictionaryForFieldService.getDataScode(params));	//数据权限查询条件SQL语句
        return tcwCapitalBusinessCostMapper.select(params);
    }


    @Override
    @Transactional
    public AjaxResult saveData(Map<String, Object> params) {
        params.put("businessEntity", new TcwCapitalBusinessCost());
        AjaxResult ajaxResult = this.saveDataBase(params);
        Map<String, Object> infoMap = (Map<String, Object>) ajaxResult.get("infoMap");
        String resNid = infoMap.get("nid").toString();

        //Map转TcwCapitalBusinessCost
        TcwCapitalBusinessCost tcwCapitalBusinessCost = JSON.parseObject(params.get("infoMap").toString(), TcwCapitalBusinessCost.class);


        List<TcwCapitalBusinessCostSon> onSonData = new ArrayList<>();
        if (params.containsKey("sonData")){
            onSonData = JSON.parseArray(params.get("infoItems").toString(), TcwCapitalBusinessCostSon.class);
        }

        List<RecordCheck> guidMapList = tcwCapitalBusinessCostMapper.findRecords(resNid);

        Map<String, Object> guidMap = new HashMap<String, Object>();
        if (!guidMapList.isEmpty()){
            if (infoMap.get("newNid") != null && "1".equals(infoMap.get("newNid").toString())){ //单号重复验证
                throw new RuntimeException(MessageUtils.message("module.error.retry"));
            }
            for (RecordCheck recordCheck : guidMapList){
                if (recordCheck != null && recordCheck.getGuid() != null){
                    guidMap.put(recordCheck.getGuid().toString(), "1");
                }
            }
        }
        if (onSonData == null || onSonData.size() == 0){
            resNid = "0";
        }else{
            resNid = infoMap.get("nid").toString();
            String guid = "";
            //获取Guid
            if (tcwCapitalBusinessCost.getGuid() == null){
                guid = RandomValueUtils.getGUID();
                tcwCapitalBusinessCost.setGuid(guid);
            }else{
                guid = tcwCapitalBusinessCost.getGuid().toString();
            }
            for (String field : infoMap.keySet()) { //遍历非网格字段，并赋值到实体中
                Object fieldValue = infoMap.get(field);
                ReflectUtils.setValue(tcwCapitalBusinessCost, field, fieldValue);
            }

            //验证资金登记认领表是否已被认领
            String hasChoosePaymentBankName = null;
            for (TcwCapitalBusinessCostSon item : onSonData){
                List<TcwCapitalRegisterClaim> checkHasChoosed = tcwCapitalRegisterClaimMapper.checkHasChoosed(item.getCapitalRegisterClaimId());
                if(checkHasChoosed!=null && checkHasChoosed.size()>0){
                    hasChoosePaymentBankName = checkHasChoosed.get(0).getPaymentBankName() +"已被认领！";
                }
            }
            if(hasChoosePaymentBankName!=null){
                return AjaxResult.error(hasChoosePaymentBankName);
            }

            if (guidMap.get(guid) == null){//新增
                //另外参数
                tcwCapitalBusinessCost.setStatus(0);
                tcwCapitalBusinessCost.setDeleted(false);
                tcwCapitalBusinessCostMapper.insert(tcwCapitalBusinessCost);
            }else{//修改
                tcwCapitalBusinessCost.setStatus(1);
                tcwCapitalBusinessCostMapper.update(tcwCapitalBusinessCost);
            }
            //查询有无旧详情数据
            List<TcwCapitalBusinessCostSon> lodData = tcwCapitalBusinessCostSonMapper.queryListCode(tcwCapitalBusinessCost.getBid());
            //若存在，删除后新增
            if (lodData.size()>0){
                for (TcwCapitalBusinessCostSon item : lodData
                ) {
                    tcwCapitalBusinessCostSonMapper.delete(item);
                    //删除认领申请后修改信息
                    TcwCapitalRegisterClaim tcwCapitalRegisterClaim = new TcwCapitalRegisterClaim();
                    tcwCapitalRegisterClaim.setId(item.getCapitalRegisterClaimId());//id
                    tcwCapitalRegisterClaimMapper.updateByDelCapital(tcwCapitalRegisterClaim);
                }
            }
            //新增
            for (TcwCapitalBusinessCostSon item : onSonData
            ) {
                item.setpBid(tcwCapitalBusinessCost.getBid());
                item.setStatus(0);
                tcwCapitalBusinessCostSonMapper.insert(item);
                //认领后修改认领表信息
                TcwCapitalRegisterClaim tcwCapitalRegisterClaim = new TcwCapitalRegisterClaim();
                //tcwCapitalRegisterClaim.setClaimTime(new Date());//认领时间
                tcwCapitalRegisterClaim.setClaimCompanyCode(tcwCapitalBusinessCost.getClaimCompanyCode());//认领公司编码
                tcwCapitalRegisterClaim.setClaimCompanyAbbreviation(tcwCapitalBusinessCost.getClaimCompanyAbbreviation());//认领公司简称
                tcwCapitalRegisterClaim.setClaimCompanyName(tcwCapitalBusinessCost.getClaimCompanyName());//认领公司名称
                tcwCapitalRegisterClaim.setId(item.getCapitalRegisterClaimId());//id
                tcwCapitalRegisterClaimMapper.updateByCapital(tcwCapitalRegisterClaim);
            }
        }

        return AjaxResult.success(MessageUtils.message("module.success.issuccess"),resNid);
    }

    /**
     *@Description: 查询前一单NID、BID
     *@Param: [params] nid 必要参数：当前 单据编码
     *@return: com.dhecp.common.core.domain.AjaxResult  (data.nid 前一单NID， data.bid 前一单BID)
     *@Author: hlf
     *@date: 2022-05-09 10:08
     */
    @Override
    public AjaxResult queryLastNid(Map<String, Object> params) throws Exception {
        Map<String, Object> dataMap = new HashMap<String, Object>();
        if (params.get("nid") == null || params.get("nid") == ""){
            params.put("nid", "0");
        }
        params.put(DataFiltering.TABLE_ALIAS, "t1");	//查询表别名
        params.put(DataFiltering.DATA_SCODE, dictionaryForFieldService.getDataScode(params));	//数据权限查询条件SQL语句
        ModuleNID moduleNID = tcwCapitalBusinessCostMapper.selectLastNid(params);
        if (moduleNID == null){
            dataMap.put("nid", "0");
            dataMap.put("bid", "0");
            return AjaxResult.warn(MessageUtils.message("module.warn.isfirstnid"), TypeUtils.mapToJson(dataMap).toString());
        }
        dataMap.put("nid", moduleNID.getNid().toString());
        dataMap.put("bid", moduleNID.getBid().toString());
        return AjaxResult.success(MessageUtils.message("module.success.issuccess"), TypeUtils.mapToJson(dataMap).toString());
    }


    /**
     *@Description: 查询后一单NID、BID
     *@Param: [params] nid 必要参数：当前 单据编码
     *@return: com.dhecp.common.core.domain.AjaxResult  (data.nid 后一单NID， data.bid 后一单BID)
     *@Author: hlf
     *@date: 2022-05-09 10:09
     */
    @Override
    public AjaxResult queryNextNid(Map<String, Object> params) throws Exception {
        Map<String, Object> dataMap = new HashMap<String, Object>();
        if (params.get("nid") == null || params.get("nid") == "" || "0".equals(params.get("nid").toString())){
            dataMap.put("nid", "0");
            dataMap.put("bid", "0");
            return AjaxResult.warn(MessageUtils.message("module.warn.isfinallynid"), TypeUtils.mapToJson(dataMap).toString());
        }
        params.put(DataFiltering.TABLE_ALIAS, "t1");	//查询表别名
        params.put(DataFiltering.DATA_SCODE, dictionaryForFieldService.getDataScode(params));	//数据权限查询条件SQL语句
        ModuleNID moduleNID = tcwCapitalBusinessCostMapper.selectNextNid(params);
        if (moduleNID == null){
            dataMap.put("nid", "0");
            dataMap.put("bid", "0");
            return AjaxResult.warn(MessageUtils.message("module.warn.isfinallynid"), TypeUtils.mapToJson(dataMap).toString());
        }
        dataMap.put("nid", moduleNID.getNid().toString());
        dataMap.put("bid", moduleNID.getBid().toString());
        return AjaxResult.success(MessageUtils.message("module.success.issuccess"), TypeUtils.mapToJson(dataMap).toString());
    }

    /**
     *@Description: 流转  —— 添加流程任务、修改流程状态及生效标志
     *@Param: [params] tableDataId 必要参数：单据编码（nid）
     *@return: com.dhecp.common.core.domain.AjaxResult
     */
    @Override
    @Transactional(timeout=120,propagation= Propagation.REQUIRES_NEW)
    public AjaxResult updateFlowGo(Map<String, Object> params) throws Exception{
        System.out.println("params"+params);
        Map<String, Object> infoMap = new HashMap<String, Object>();
        String nid = "0";
        //验证nid
        if (params.get("tableDataId") == null || params.get("tableDataId") ==""){
            return AjaxResult.error(MessageUtils.message("module.error.lack","单据编码【tableDataId】"));
        }else{
            nid = params.get("tableDataId").toString();
        }
        params.put("nid", nid);
        List<TcwCapitalBusinessCost> businessDataList = tcwCapitalBusinessCostMapper.selectByNid(params);
        if (businessDataList == null || businessDataList.size() == 0){
            return AjaxResult.error(MessageUtils.message("module.error.nodata"));
        }else{
            infoMap.put("cid", businessDataList.get(0).getCid());
            infoMap.put("bUser", businessDataList.get(0).getbUser());
            infoMap.put("bDept", businessDataList.get(0).getbDept());
            infoMap.put("procInstId", businessDataList.get(0).getProcInstId());
            infoMap.put("activeFlow", businessDataList.get(0).getActiveFlow());
            infoMap.put("createTime", businessDataList.get(0).getCreateTime());
            params.put("infoMap", TypeUtils.mapToJson(infoMap).toString());
            params.put("activeFlowOld", businessDataList.get(0).getActiveFlow());
        }

        //流程处理公共方法，返回单据（流转、回退等）后的流程状态信息
        if (params.get("optType") == null || params.get("optType") == ""){
            params.put("optType", "go");
        }
        UpdateFlow updateFlow = new UpdateFlow();
        updateFlow = this.FlowDealBase(params);

        if (businessDataList!=null && businessDataList.size()>0) {
            TcwCapitalBusinessCost businessData = businessDataList.get(0);
            updateFlow.setGuid(businessData.getGuid().toString());
            //Date now = new Date();
            tcwCapitalBusinessCostMapper.updateFlow(updateFlow);//修改状态

            //审批结束
            if (updateFlow.getActiveFlow().equals("end")){

                //获取详情信息
                List<TcwCapitalBusinessCostSon> tcwCapitalBusinessCostSonList = tcwCapitalBusinessCostSonMapper.queryListCode(businessData.getBid());
                for (TcwCapitalBusinessCostSon sonItem : tcwCapitalBusinessCostSonList){
                    //修改资金登记认领表认领时间
                    TcwCapitalRegisterClaim tcwCapitalRegisterClaim = new TcwCapitalRegisterClaim();
                    tcwCapitalRegisterClaim.setClaimTime(updateFlow.getUpdateTime());//认领时间
                    tcwCapitalRegisterClaim.setId(sonItem.getCapitalRegisterClaimId());//id
                    tcwCapitalRegisterClaimMapper.update(tcwCapitalRegisterClaim);

                    //新增流水
                    addAccountDetailedForCompany(businessData.getClaimCompanyCode(),"GS0874",sonItem.getPaymentAmount(),
                            sonItem.getCreateTime(),updateFlow.getUpdateTime(),sonItem.getPaymentTime(),"运营费用认领单："+businessData.getBid(),"运营费用认领单",1,
                            businessData.getNid(),businessData.getBid(),businessData.getGuid(),"运营服务→预付款");

                    addAccountDetailedForCompany("GS0874",businessData.getClaimCompanyCode(),BigDecimal.ZERO.subtract(sonItem.getPaymentAmount()),
                            sonItem.getCreateTime(),updateFlow.getUpdateTime(),sonItem.getPaymentTime(),"运营费用认领单："+businessData.getBid(),"运营费用认领单",1,
                            businessData.getNid(),businessData.getBid(),businessData.getGuid(),"运营服务→预付款");
                }
            }
        }

        return AjaxResult.success(MessageUtils.message("module.success.issuccess"), nid);
    }

    //新增流水
    public void addAccountDetailedForCompany(String vGsBm,String vGsBmP,BigDecimal fJe,
                                             Date dJySj,Date dShSj,Date writeTime,String vBz,String mName,Integer mType,
                                             String mNid,String mBid,String mGuid,String vJyLx) throws Exception{
        OperateCompanyApply operateCompanyApply = operateCompanyApplyMapper.findVGsBm(vGsBm);
        OperateCompanyApply operateCompanyApplyP = operateCompanyApplyMapper.findVGsBm(vGsBmP);

        //AccountCountForCompany accountCountForCompany = accountCountForCompanyMapper.findByVGsBm(vGsBmP);
        //Date now = new Date();
        AccountDetailedForCompany entity = new AccountDetailedForCompany();
        entity.setGuid(RandomValueUtils.getGUID());
        entity.setvGsBm(vGsBm);
        entity.setvGsJc(operateCompanyApply.getvGsJc());
        entity.setvGsMc(operateCompanyApply.getvGsMc());
        entity.setvYhZh(operateCompanyApply.getvYhZh());
        entity.setvGsBmP(vGsBmP);
        entity.setvGsJcP(operateCompanyApplyP.getvGsJc());
        entity.setvGsMcP(operateCompanyApplyP.getvGsMc());
        entity.setvYhZhP(operateCompanyApplyP.getvYhZh());
        //entity.setvZhLx(accountCountForCompany.getvZhLx());//账户类型

        entity.setvJyLx(vJyLx);//交易类型
        entity.setfJe(fJe.doubleValue());//交易金额
        entity.setdJySj(dJySj);//交易时间
        entity.setdShSj(dShSj);//审核时间
        entity.setvBz(vBz);//备注
        if(mName!=null)entity.setmName(mName);
        if(mType!=null)entity.setmType(mType);
        if(mNid!=null)entity.setmNid(mNid);
        if(mBid!=null)entity.setmBid(mBid);
        if(mGuid!=null)entity.setmGuid(mGuid);
        entity.setWriteTime(writeTime!=null?writeTime:dShSj);
        accountDetailedForCompanyMapper.insertAccountDetailedForCompany(entity);
    }

    /**
     *@Description: 退回  —— 添加流程任务、修改流程状态及生效标志
     *@Param: [params] tableDataId 必要参数：单据编码（nid）
     */
    @Override
    @Transactional(timeout=120,propagation= Propagation.REQUIRES_NEW)
    public AjaxResult updateFlowBack(Map<String, Object> params) throws Exception {
        Map<String, Object> infoMap = new HashMap<String, Object>();
        String nid = "0";
        if (params.get("tableDataId") == null || params.get("tableDataId") ==""){
            return AjaxResult.error(MessageUtils.message("module.error.lack","单据编码【tableDataId】"));
        }else{
            nid = params.get("tableDataId").toString();
        }
        params.put("nid", nid);
        List<TcwCapitalBusinessCost> businessDataList = tcwCapitalBusinessCostMapper.selectByNid(params);
        if (businessDataList == null || businessDataList.size() == 0){
            return AjaxResult.error(MessageUtils.message("module.error.nodata"));
        }else{
            infoMap.put("cid", businessDataList.get(0).getCid());
            infoMap.put("bUser", businessDataList.get(0).getbUser());
            infoMap.put("bDept", businessDataList.get(0).getbDept());
            infoMap.put("procInstId", businessDataList.get(0).getProcInstId());
            infoMap.put("activeFlow", businessDataList.get(0).getActiveFlow());
            infoMap.put("createTime", businessDataList.get(0).getCreateTime());
            params.put("infoMap", TypeUtils.mapToJson(infoMap).toString());
            params.put("activeFlowOld", businessDataList.get(0).getActiveFlow());
        }

        //流程处理公共方法，返回单据（流转、回退等）后的流程状态信息
        if (params.get("optType") == null || params.get("optType") == ""){
            params.put("optType", "back");
        }
        UpdateFlow updateFlow = new UpdateFlow();
        updateFlow = this.FlowDealBase(params);

        //for (TcwCapitalBusinessCost businessData : businessDataList) {
        if (businessDataList!=null && businessDataList.size()>0) {
            TcwCapitalBusinessCost businessData = businessDataList.get(0);
            updateFlow.setGuid(businessData.getGuid().toString());
            tcwCapitalBusinessCostMapper.updateFlow(updateFlow);
            //Date now = new Date();
            if (infoMap.get("activeFlow").equals("end")){
                //获取详情信息
                List<TcwCapitalBusinessCostSon> tcwCapitalRegisterSonList = tcwCapitalBusinessCostSonMapper.queryListCode(businessData.getBid());
                for (TcwCapitalBusinessCostSon sonItem : tcwCapitalRegisterSonList){
                    //认领申请审批回退时修改资金登记认领表信息
                    TcwCapitalRegisterClaim tcwCapitalRegisterClaim = new TcwCapitalRegisterClaim();
                    tcwCapitalRegisterClaim.setId(sonItem.getCapitalRegisterClaimId());//id
                    tcwCapitalRegisterClaimMapper.updateByCapitalFlowBack(tcwCapitalRegisterClaim);

                    //新增流水-回退
                    addAccountDetailedForCompany(businessData.getClaimCompanyCode(),"GS0874",BigDecimal.ZERO.subtract(sonItem.getPaymentAmount()),
                            sonItem.getCreateTime(),updateFlow.getUpdateTime(),sonItem.getPaymentTime(),"（回退）运营费用认领单："+businessData.getBid(),"运营费用认领单",1,
                            businessData.getNid(),businessData.getBid(),businessData.getGuid(),"运营服务→预付款（回退）");

                    addAccountDetailedForCompany("GS0874",businessData.getClaimCompanyCode(),sonItem.getPaymentAmount(),
                            sonItem.getCreateTime(),updateFlow.getUpdateTime(),sonItem.getPaymentTime(),"（回退）运营费用认领单："+businessData.getBid(),"运营费用认领单",1,
                            businessData.getNid(),businessData.getBid(),businessData.getGuid(),"运营服务→预付款（回退）");


                }
            }
        }

        return AjaxResult.success(MessageUtils.message("module.success.issuccess"), nid);
    }



    /**
     * 删除运营费用认领单数据
     * @param
     * @return
     * @author DH-Xxj
     */
    @Override
    @Transactional(timeout=120,propagation= Propagation.REQUIRES_NEW)
    public AjaxResult delete(Map<String, Object> params) {
        List<TcwCapitalBusinessCost> tcwCapitalBusinessCostList = JSON.parseArray(params.get("infoItems").toString(), TcwCapitalBusinessCost.class);
        if (tcwCapitalBusinessCostList == null || tcwCapitalBusinessCostList.size() == 0) {
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return AjaxResult.error("数据异常!");
        }
        if (tcwCapitalBusinessCostList!=null) {
            TcwCapitalBusinessCost tcwCapitalBusinessCost = tcwCapitalBusinessCostList.get(0);
            tcwCapitalBusinessCostMapper.delete(tcwCapitalBusinessCost.getGuid());


            //获取详情信息后删除并修改认领状态
            List<TcwCapitalBusinessCostSon> tcwCapitalBusinessCostSonList = tcwCapitalBusinessCostSonMapper.queryListCode(tcwCapitalBusinessCost.getBid());
            for (TcwCapitalBusinessCostSon sonItem : tcwCapitalBusinessCostSonList){
                tcwCapitalBusinessCostSonMapper.deleteByPBid(tcwCapitalBusinessCost.getBid());
                TcwCapitalRegisterClaim tcwCapitalRegisterClaim = new TcwCapitalRegisterClaim();
                tcwCapitalRegisterClaim.setId(sonItem.getCapitalRegisterClaimId());
                tcwCapitalRegisterClaimMapper.updateByDelCapital(tcwCapitalRegisterClaim);
            }


            String procInstId = tcwCapitalBusinessCost.getProcInstId();
            if (procInstId != null && !"".equals(procInstId)) {
                actProcessService.deleteProcess(procInstId);
                //插入指定单据流转各环节审批人记录（单据删除记录）
                Map<String, Object> flowRecord = new HashMap<String, Object>();
                flowRecord.put("moduleTable", moduleTable);
                flowRecord.put("nid", tcwCapitalBusinessCost.getNid());
                flowRecord.put("activeFlowOld", "FlowZd");
                flowRecord.put("procInstId", procInstId);
                flowRecord.put("createUser", ShiroUtils.getMandatorId());
                flowRecord.put("createUserName", ShiroUtils.getMandatorName());
                flowRecord.put("updateUsers", "实际删除操作人： " + ShiroUtils.getUserName() + "【" + ShiroUtils.getUserId() + "】");
                flowRecord.put("optType", "delete");
                processInstanceMapper.insertProcessInstanceFlowRecord(flowRecord);
            }
        }
        return AjaxResult.success(MessageUtils.message("module.success.issuccess"));
    }

}

